﻿
Imports osi.root.connector

Public Class map_pair(Of KEY_T, VALUE_T)
    Implements IComparable(Of map_pair(Of KEY_T, VALUE_T)), ICloneable
    Public ReadOnly first As KEY_T
    Public second As VALUE_T

    Public Sub New(ByVal first As KEY_T, ByVal second As VALUE_T)
        Me.first = first
        Me.second = second
    End Sub

    Public Sub New(ByVal first As KEY_T)
        Me.New(first, Nothing)
    End Sub

    Public Function CompareTo(ByVal other As map_pair(Of KEY_T, VALUE_T)) As Int32 _
                             Implements IComparable(Of map_pair(Of KEY_T, VALUE_T)).CompareTo
        Dim c As Int32 = 0
        c = object_compare(Me, other)
        If c = object_compare_undetermined Then
            k_assert(Not other Is Nothing)
            Return compare(first, other.first)
        Else
            Return c
        End If
    End Function

    Public Function Clone() As Object Implements ICloneable.Clone
        Return New map_pair(Of KEY_T, VALUE_T)(copy_no_error(first), copy_no_error(second))
    End Function
End Class
